#include "interface_control.h"
#include "client_connet.h"
#include "findeuser.h"
#include "ui_findeuser.h"
#include "findur.h"

#include <QScrollArea>

FindeUser::FindeUser(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FindeUser)
{
//    ui->setupUi(this);
    this->resize(800,800);
    qDebug()<<"断点5";
    QScrollArea* scl = new QScrollArea(this);
    scl->setGeometry(0,0,800,800);
    QString styleSheet = "QScrollBar:vertical {"
                         "    width: 5px; /* 设置一个很小的宽度 */"
                         "    background: transparent; /* 设置背景透明 */"
                         "    border: none; /* 移除边框 */"
                         "    margin: 0px; /* 移除外边距 */"
                         "    padding: 0px; /* 移除内边距 */"
                         "    /* 这里可以添加滚动条滑块（handle）的样式 */"
                         "    QScrollBar::handle:vertical {"
                         "        background: rgba(255, 255, 255, 128); /* 半透明滑块背景 */"
                         "        min-height: 20px; /* 设置滑块的最小高度 */"
                         "        border-radius: 2px; /* 设置滑块边框圆角 */"
                         "    }"
                         "}"
                         "QScrollBar:horizontal {"
                         "    height: 5px; /* 设置水平滚动条的高度 */"
                         "    background: transparent; /* 设置背景透明 */"
                         "    border: none; /* 移除边框 */"
                         "    margin: 0px; /* 移除外边距 */"
                         "    padding: 0px; /* 移除内边距 */"
                         "    /* 这里可以添加水平滚动条滑块的样式 */"
                         "}";
    scl->setStyleSheet(styleSheet);

    finduser_widget = new QWidget(this);
    finduser_widget->move(0,0);

    finduser_vl = new QVBoxLayout(finduser_widget);
    finduser_vl->setSpacing(0);

    scl->setWidget(finduser_widget);

}


FindeUser::~FindeUser()
{
    delete ui;
}

void FindeUser::AddFriend(QString id, QString name)
{
    qDebug()<<"查询添加";
    findUses += 100;
    finduser_widget->resize(790,findUses);
    Findur *fr = new Findur(finduser_widget,id,name);
    finduser_vl->addWidget(fr);
}

void FindeUser::allFind()
{
    int num = Client_connet::Get_Connet()->frarr.size();
   //初始化主界面与聊天界面
    qDebug()<<"数组长度:"<<num;

    for(int i = 0; i < num; ++i)
    {
        qDebug()<<"初始化查询对象："<<i;
        AddFriend(Client_connet::Get_Connet()->find_arr[i].ID,Client_connet::Get_Connet()->find_arr[i].name);

    }
}


